import 'package:flutterhello/util/host_util.dart';
import 'package:get/get.dart';
import 'package:web_socket_channel/io.dart';

class ChatController extends GetxController {
  IOWebSocketChannel channel;
  var groupPaintList = new Map<String, List<String>>();

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
  }

  connection() {
    channel = new IOWebSocketChannel.connect("ws://" +
        HostUtil.getChatHost() +
        ":8080?userID=6097d8d4c1102a36903b5871");
    channel.stream.listen((event) {
      print(event);
    }, onError: (err) {
      print('-------------error--------------');
      print(err);
    });
  }

  setData() {
    groupPaintList = {
      '6097d8a5f323b36b0039bdbe': [
        "{'groupname':'专业团队','favicon':'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg9.51tietu.net%2Fpic%2F2019-091318%2F2nnnv5kpdzj2nnnv5kpdzj.jpg&refer=http%3A%2F%2Fimg9.51tietu.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1623169139&t=b32d713eb03396fd90d2f742ba9a85b3'}"
      ]
    };
  }
}
